﻿using log4net;
using System.Reflection;

namespace Shininglore.Security
{
    class AuthServiceHandler : AuthService.Iface
    {
        // Create a logger for use in this class
        private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
        private string currentHash;

        public AuthServiceHandler(string currentHash)
        {
            this.currentHash = currentHash;
        }
        
        public bool ValidateHash(string hash)
        {
            //TODO: how to get the socket context?
            log.InfoFormat("Validating {0}...", hash);

            if (hash == currentHash)
            {
                log.Info("PASS");
                return true;
            }
            else
            {
                log.Info("FAIL");
                return false;
            }
        }
    }
}
